//-------------------------------------------------------------------
//	Copyright (c) 2010-2012 Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_VIDEO_RENDER_H
#define _UX_VIDEO_RENDER_H

#include "IVideoEncoder.h"

namespace Engine
{
namespace RenderUtils
{

	//
	// RealTime Video Render
	//

	class _EXPORT_ CVideoRender : public CEngBaseObject
	{
	private:
		IVideoEncoder *	_pEncoder;
		binary_buffer_t	_aFrameData;
		urect			_sArea;
		float			_fTimeDelta,
						_fTime;
		TThread			_sThread;
		TEventSync		_sEventRead,
						_sEventSave;
		const bool		_bInThread;

		void _SaveFrame();

		static uint CALLBACK _s_ThreadProc(void *pParametr);

	public:
		CVideoRender(IVideoEncoder *pEncoder, bool bInThread);
		~CVideoRender();

		bool Create(const char * pFileName, const urect &sArea, uint uFrameRate, e_video_create::type eType);
		void Close();

		// in render
		bool AddFrame();

		bool SetVideoEncoder(IVideoEncoder *pVideo);

		IVideoEncoder * GetVideoEncoder()	const	{ return _pEncoder; }
	};

//-------------------------------------------------------------------

}	// RenderUtils
}	// Engine

#endif	// _UX_VIDEO_RENDER_H